#!/bin/sh
#
# $Id: LTSP-BalanC .init.d,v 1.5 2003/07/13 19:12:41 mdz Exp $
#
#**
#*      Reparto de carga para clientes delgados del Producto LTSP-BalanC 
#*
#*
#**
#


PRORC=/usr/local/bin/prorc.py
test -f $PRORC || exit 0


ARCH_PID=/var/run/prorc.pid

case "$1" in
        start)
                echo -n "Iniciando LTSP-BalanC : "
                logger -i -t ProRC "Balance de Carga LTSP-BalanC -- INICIADO"
                start-stop-daemon --start --background --quiet --pidfile $ARCH_PID \
                        --exec $PRORC -- --pid=$ARCH_PID >> /var/log/prorc.init.log 2>&1
                sleep 2

                if [ -f "$ARCH_PID" ] && ps h `cat "$ARCH_PID"` >/dev/null; then
                        echo "ProRC OK."
                else
                        echo "Error al iniciar prorc.py.... !!!"
                        exit 1
                fi
                ;;
        stop)
                echo -n "Finalizando LTSP-BalanC :"
                logger -i -t ProRC "Balance de Carga LTSP-BalanC -- DETENIDO"
                start-stop-daemon --stop --quiet --pidfile  $ARCH_PID
                echo "."
                ;;
        restart | force-reload)
                $0 stop
                sleep 3
                $0 start
                if [ "$?" != "0" ]; then
                        exit 1
                fi
                ;;
        *)
                echo "Usar: /etc/init.d/prorc.init {start|stop|restart}"
                exit 1 
esac

exit 0

